home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9917 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: s02.pavilion.co.uk!usenet
  2. From: AJRobb@pavilion.co.uk (Andy J Robb)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Leap year
  5. Date: Tue, 05 Mar 1996 03:37:11 GMT
  6. Organization: Pavilion Internet plc
  7. Message-ID: <4hgcrs$2kl@s02.pavilion.co.uk>
  8. References: <3135A7F2.2120@hiwaay.net> <4hbiln$899@sam.inforamp.net>
  9. NNTP-Posting-Host: poolc35.pavilion.co.uk
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. rmorin@inforamp.net (Randy Charles Morin) wrote:
  13.  
  14. >In article <3135A7F2.2120@hiwaay.net>, Lance Perry <lperry@hiwaay.net> wrote:
  15. >>Can someone be kind enough to post the formula for Leap Year
  16. >>or point me to the place where this can be found?
  17. >>
  18. >>lperry@hiwaay.net
  19.  
  20. >bool IsLeapYear(int x)
  21. >{
  22. >    return ((x&4) && ((!(x&100)) || (x&1000)));
  23. >}
  24.  
  25. >I hope I got everything right.
  26.  
  27. -----BEGIN PGP SIGNED MESSAGE-----
  28.  
  29. Sorry guy, no you didn't.
  30.  
  31.     (!(x%400)) || ((x%100) && (!(x%4))
  32.  
  33. My main point, it that every 400 years is currently defined as a leap
  34. year (not 1000 years as you indicated) whereas, at every other 100
  35. years it is not.  Thus 2000 is a leap year, as would be 2400.
  36. Whereas, 1800, 1900 were not leap years.  Generally, systems dealing
  37. in current time are safe to use:
  38.  
  39.  !(x & 3)
  40.  
  41. There will not be a potential problem until 2100, and whos to say we
  42. will still be using a Christian calender then.
  43.  
  44. Regards,
  45. Andy Robb.
  46.  
  47. -----BEGIN PGP SIGNATURE-----
  48. Version: 2.6.2i
  49.  
  50. iQCVAwUBMTu2pJPl4P16x9sNAQEf6gQAoSBrott9tJ41oqrGoKYaUQ/hL2IXL6rC
  51. ++ienee2EprqxkOp466PFRnHEZPAbOB05KjEKs0/2UShZM5z2Cs1FnQlglrCuZVB
  52. K8DERgflk4e53xm/xrBfrHKW3LCvI1B4qwkvECmMPYt0fANrhVZs1aF9vTbpE6Bf
  53. 1I4qR+ga2P8=
  54. =i21/
  55. -----END PGP SIGNATURE-----
  56.  
  57.  
  58.